package com.ch3cooh.registry.pojo;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @功能: 向zookeeper注册的服务 相关信息
 * @作者:chanson
 * @时间:2018/4/27 22:49
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
public class RegisterInfo {

    private static final  String HTTP = "http://";

    /* 主机名或者ip*/
    private String host;

    /* 端口号*/
    private int port;

    /* 计算机名 */
    private String computerName;

    /* 主机端口号*/
    private String hostUrl;

    /* 服务名*/
    private String serverName;

    public String getHttpHostUrl(){
        return HTTP+hostUrl;
    }

    public static void main(String[] args) {
        String str ="{\"computerName\":\"SKY-20170903RBH\",\"host\":\"192.168.1.165\",\"hostUrl\":\"192.168.1.165:9998\",\"httpHostUrl\":\"http://192.168.1.165:9998\",\"port\":9998,\"serverName\":\"server-1\"}";
        RegisterInfo registerInfo = JSON.parseObject(str, RegisterInfo.class);
        System.out.println(registerInfo);
    }
}
